<script setup>
import { computed, ref } from "vue";
import { useStore } from "vuex";

const store = useStore();
const resultList = computed(() => store.state.resultList);
const pageIndex = computed(() => store.state.pageIndex);
const handleHome = () => {
  store.commit("setState", { pageIndex: -1 });
};
</script>

<template>
  <div class="box">
    <div class="title">
      <span>声鉴报告</span>
      <div class="back" @click="handleHome">←</div>
    </div>
    <div class="scroll-view">
      <div class="emtpy" v-if="!resultList.length">声鉴结果是空的</div>
      <div class="res-item" v-for="(item, index) in resultList" :key="index">
        <div class="key">{{ item.key }}:</div>
        <div class="value">{{ item.value || "/" }}</div>
      </div>
    </div>
  </div>
</template>

<style lang="scss" scoped>
.box {
  background-color: #fff;
  color: #000;
  width: 266px;
  height: 355px;
  box-sizing: border-box;
  margin: 10px auto 0;
  position: relative;
  .title {
    text-align: center;
    font-size: 24px;
    height: 42px;
    line-height: 42px;
    font-weight: bold;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    box-shadow: 0px -7px 20px 1px rgba(0, 0, 0, 0.1);
    .back {
      position: absolute;
      left: 0;
      top: 0;
      height: 42px;
      width: 42px;
      display: flex;
      justify-content: center;
      align-items: center;
      cursor: pointer;
      &:hover {
        color: plum;
      }
    }
  }
  .scroll-view {
    position: absolute;
    top: 42px;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: calc(100% - 42px);
    overflow-y: scroll;
    overflow-x: hidden;
    padding: 20px 15px;
    box-sizing: border-box;
    &::-webkit-scrollbar {
      width: 4px;
      background-color: transparent;
    }
    &::-webkit-scrollbar-thumb {
      width: 4px;
      background-color: #c8efd4;
      border-radius: 2px;
    }
  }
  .res-item {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
    border-bottom: 1px solid #aaa;
    margin-top: 5px;
    &:first-of-type {
      margin-top: 0;
    }
    .key {
      width: 6em;
      height: max-content;
      padding-left: 0.5em;
      position: relative;
      &::before {
        content: "";
        display: block;
        position: absolute;
        top: 0;
        bottom: 0;
        left: 0;
        width: 4px;
        border-radius: 2px;
        background-color: #c8ebfa;
      }
    }
    .value {
      flex: 1;
    }
  }
}
</style>